﻿Imports System.Data.SqlClient
Public Class clsFactores
    Private mintIdFactor As Integer
    Private mintAntiguedad As Integer
    Private mdblFactor As Double
    Public Property IdFactor() As Integer
        Get
            Return mintIdFactor
        End Get
        Set(ByVal value As Integer)
            mintIdFactor = value
        End Set
    End Property
    Public Property Antiguedad() As Integer
        Get
            Return mintAntiguedad
        End Get
        Set(ByVal value As Integer)
            mintAntiguedad = value
        End Set
    End Property
    Public Property Factor() As Double
        Get
            Return mdblFactor
        End Get
        Set(ByVal value As Double)
            mdblFactor = value
        End Set
    End Property

    Public Sub New()
        mintIdFactor = 0
        mintAntiguedad = 0
        mdblFactor = 0
    End Sub
       Public Sub Insertar()
        Dim sql As String = "Insert Into Factores (" & _
                            "IdFactor," & _
                            "Antiguedad," & _
                            "Factor) " & _
                            "VALUES (" & _
                            "@IdFactor," & _
                            "@Antiguedad," & _
                            "@Factor)"



        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("IdFactor", mintIdFactor)
        Command.Parameters.AddWithValue("Antiguedad", mintAntiguedad)
        Command.Parameters.AddWithValue("Factor", mdblFactor)

        cnConn.Open()
        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar el factor ", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub
End Class
